import { api } from '@/utils/request'
import type { QARecord, CreateQARecordRequest, UpdateQARecordRequest } from '@/types/qa'

// 获取所有问答记录
export const getQARecords = () => {
  return api.get<QARecord[]>('/qa-records')
}

// 创建问答记录
export const createQARecord = (data: CreateQARecordRequest) => {
  return api.post<QARecord>('/qa-records', data)
}

// 更新问答记录
export const updateQARecord = (id: number, data: UpdateQARecordRequest) => {
  return api.put<QARecord>(`/qa-records/${id}`, data)
}

// 删除问答记录
export const deleteQARecord = (id: number) => {
  return api.delete(`/qa-records/${id}`)
}

// 获取已删除的问答记录（回收站）
export const getDeletedQARecords = () => {
  return api.get<QARecord[]>('/qa-records/deleted')
}

// 恢复问答记录
export const restoreQARecord = (id: number) => {
  return api.put(`/qa-records/${id}/restore`)
}

// 永久删除问答记录
export const permanentDeleteQARecord = (id: number) => {
  return api.delete(`/qa-records/${id}/permanent`)
}
